/**
 *    Copyright 2009-2015 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.apache.ibatis.reflection.wrapper;

import java.util.List;

import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.apache.ibatis.reflection.property.PropertyTokenizer;

/**
 *  对象包装器,通过这个对象可以简单的完成对象的属性的获取和设置
 */
public interface ObjectWrapper {
  
	
   /**
    * 如果对象是普通的对象类型,那么就会调用对应的get和set方法,
    * 如果是集合的类型,那么就会调用对应的下标和对应的key来获取属性值	
    */
	
  /**
   * 通过分词器获取对象
   * @param prop
   * @return
   */
  Object get(PropertyTokenizer prop);
  
  /**
   * 给对象的某一个属性设置值
   * @param prop
   * @param value
   */
  void set(PropertyTokenizer prop, Object value);
  
  /**
   * 通过属性的名称
   * @param name
   * @param useCamelCaseMapping
   * @return
   */
  String findProperty(String name, boolean useCamelCaseMapping);
  
  /**
   * 获取get的属性的名称合集
   * @return
   */
  String[] getGetterNames();
  /**
   * 获取set属性的集合
   * @return
   */
  String[] getSetterNames();
  
  /**
   * 获取set方法的入参值
   * @param name
   * @return
   */
  Class<?> getSetterType(String name);
  /**
   * 获取get方法的返回值
   * @param name
   * @return
   */
  Class<?> getGetterType(String name);
  /**
   * 判断是否存在set方法
   * @param name
   * @return
   */
  boolean hasSetter(String name);
  /**
   * 判断是否存在get方法
   * @param name
   * @return
   */
  boolean hasGetter(String name);
  
  MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory);
  /**
   * 判断是否是一个集合类型
   * @return
   */
  boolean isCollection();
  
  /**
   * 添加一个元素
   * @param element
   */
  void add(Object element);
  
  /**
   * 添加一组属性元素
   * @param element
   */
  <E> void addAll(List<E> element);

}
